/*
 * Problem: 贿赂囚人（Bribe the Prisoners）
 * Author: Yuanshun L
 * Created: 5-Dec-2021
 * Topic: 动态规划法
 */
#include<iostream>
#include<algorithm>

using namespace std;

const int maxn = 100 + 5;
const int maxm = 10+1;
const int inf = 10000000;
int A[maxm];
int dp[maxm][maxm];
int N,Q;

int solve(){

    // 两端墙壁也作为空牢房
    A[0] = 0;
    A[Q+1] = N+1;

    // 不需要贿赂两个空牢房之间的囚人
    for(int i=0;i<=Q;i++){
        dp[i][i+1] = 0;
    }
    for(int i=2;i<=Q+1;i++){

        for(int j=0;j<=Q+1-i;j++){ // 寻找到j到j+i之间的最小值
            int minimum = inf;

            for(int k=j+1;k<j+i;k++){
                minimum = min(minimum,dp[j][k]+dp[k][j+i]+A[j+i]-A[j]-2);
            }

            dp[j][j+i] = minimum;

        }

    }

    return dp[0][Q+1];

}

int main(){
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);

    cin >> N >> Q;
    for(int i=1;i<=Q;i++){
        cin >> A[i];
    }
    cout << solve() << endl;
    return 0;
}
